var http=require('http');
var url=require('url');
var util=require('util');
//启动服务
http.createServer(function(req,res){
  console.log('开始请求，解析参数');
  var params=url.parse(req.url,true);
  console.log('解析完成');
  console.log(util.inspect(params));
  console.log('向客户端返回name');
  res.end(params.query.name);
}).listen(8888);

//客户端请求
var request=http.get({
  host:'localhost',
  path:'/user?name=Tom&age=18&city=beijing',
  port:8888},function(res){
  res.setEncoding('utf-8');
  res.on('data',function(data){
    console.log('服务端相应name值为：'+data);
  })
});